** This file creates Figures 2.2, 2.4, and 2.5

* Open the 2010 Cooperative Congressional Election Study Common Content data 
use ccES10_Common_OUTPUT.dta, clear

* Set the data to use sampling weights
svyset [pw=v101]

* Generate issue ideology scale by adding 1 for conservative responses and subtracting
* one for liberal responses 
gen issues=0
replace issues=issues+1 if cc320==2
replace issues=issues-1 if cc320==1
replace issues=issues+1 if cc322_2==2
replace issues=issues-1 if cc322_2==1
replace issues=issues-1 if cc322_4==2
replace issues=issues+1 if cc322_4==1
replace issues=issues-1 if cc322_5==2
replace issues=issues+1 if cc322_5==1
replace issues=issues-1 if cc324==4
replace issues=issues+1 if cc324==1
replace issues=issues-1 if cc326==2
replace issues=issues+1 if cc326==1
replace issues=issues+1 if cc327==4
replace issues=issues-1 if cc327==1
replace issues=issues-1 if cc332b==1
replace issues=issues+1 if cc332b==2
replace issues=issues-1 if cc332c==1
replace issues=issues+1 if cc332c==2
replace issues=issues-1 if cc332d==1
replace issues=issues+1 if cc332d==2
replace issues=issues-1 if cc332e==1
replace issues=issues+1 if cc332e==2
replace issues=issues-1 if cc332f==1
replace issues=issues+1 if cc332f==2
replace issues=issues-1 if cc332g==1
replace issues=issues+1 if cc332g==2
replace issues=issues-1 if cc332i==1
replace issues=issues+1 if cc332i==2

* Recode not sure responses to missing
recode cc334a-cc334l (8=.)

* Generate indicators for whether individual donated to party, candidates, or groups
gen partydonor=1 if cc417bx_6==1
replace partydonor=0 if partydonor==. & cc417a_4==1

gen canddonor=1 if cc417bx_1==1 | cc417bx_2==1 | cc417bx_3==1 | cc417bx_4==1 | cc417bx_5==1 
replace canddonor=0 if canddonor==. & cc417a_4==1

gen groupdonor=1 if cc417bx_7==1 | cc417bx_8==1
replace groupdonor=0 if groupdonor==. & cc417a_4==1

* Re-label donor indicator variable for graphing
label define donors 1 "Donors" 2 "Other Adults"
label values cc417a_4 donors

* Create Figure 2.2
twoway histogram issues, by(cc417a_4, note(" ")) xtitle("Issue Positions") discrete scheme(s1mono) bc(blue) percent xlabel(-15 "         Very Liberal"  0  15 "Very Conservative                      ", labs(small)) ylabel(0 5 10, nogrid)
graph export fig_2_2.eps, replace

* Create Figure 2.4
twoway lpolyci partydonor issues, scheme(s1mono) title("Proportion of Party Donors", size(medsmall))  xlabel(-15 "Very Liberal     "  0  15 "     Very Cons.", labs(medsmall)) saving(partydonors.gph, replace) aspect(1) legend(off) xtitle(" ")
twoway lpolyci canddonor issues, scheme(s1mono) title("Proportion of Candidate Donors", size(medsmall)) xlabel(-15 "Very Liberal     "  0  15 "     Very Cons.", labs(medsmall))  saving(canddonors.gph, replace) aspect(1) legend(off) xtitle(" ")
twoway lpolyci groupdonor issues, scheme(s1mono) title("Proportion of Group Donors", size(medsmall)) xlabel(-15 "Very Liberal     "  0  15 "     Very Cons.", labs(medsmall))  saving(groupdonors.gph, replace) aspect(1) legend(off) xtitle(" ")
graph combine partydonors.gph canddonors.gph groupdonors.gph, graphr(c(white)) c(3) ycom xcom
graph export fig_2_4.eps, replace

* Create Figure 2.5
twoway lpolyci cc334d issues if cc417a_4==1 & v212a==1, clp(_) clc(black) || lpolyci cc334j issues if cc417a_4==1 & v212a==1, clc(black) || histogram issues if cc417a_4==1 & v212a==1, scheme(s1mono) ytitle("Ideological Placement") ylabel(1 "Very Lib.     "  4 "Moderate"  7 "Very Cons.     ") fc(none) lc(black) legend(lab(2 "Placement of Dem. Party") lab(4 "Placement of Dem. Candidate") lab(5 "Distribution of Observations") region(lc(white)) order(2 4 5) col(1)) title("Democratic Donors") saving(dem1.gph, replace)
twoway lpolyci cc334e issues if cc417a_4==1 & v212a==2, clp(_) clc(black) || lpolyci cc334k issues if cc417a_4==1 & v212a==2, clc(black) || histogram issues if cc417a_4==1 & v212a==2, scheme(s1mono) ytitle("Ideological Placement") ylabel(1 "Very Lib.     "  4 "Moderate" 7 "Very Cons.     ") fc(none) lc(black) legend(lab(2 "Placement of Rep. Party") lab(4 "Placement of Rep. Candidate") lab(5 "Distribution of Observations") region(lc(none)) order(2 4 5) col(1)) title("Republican Donors") saving(rep1.gph, replace)
graph combine dem1.gph rep1.gph, graphr(c(white)) ycom xcom
graph export fig_2_5.eps, replace

